home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209b.zip / octave-2.09 / doc / octave.i10 < prev    next >
Encoding:
GNU Info File  |  1997-08-20  |  42.0 KB  |  1,085 lines

  1. This is Info file octave, produced by Makeinfo-1.64 from the input file
  2. octave.tex.
  3.  
  4. START-INFO-DIR-ENTRY
  5. * Octave: (octave).     Interactive language for numerical computations.
  6. END-INFO-DIR-ENTRY
  7.  
  8.    Copyright (C) 1996, 1997 John W. Eaton.
  9.  
  10.    Permission is granted to make and distribute verbatim copies of this
  11. manual provided the copyright notice and this permission notice are
  12. preserved on all copies.
  13.  
  14.    Permission is granted to copy and distribute modified versions of
  15. this manual under the conditions for verbatim copying, provided that
  16. the entire resulting derived work is distributed under the terms of a
  17. permission notice identical to this one.
  18.  
  19.    Permission is granted to copy and distribute translations of this
  20. manual into another language, under the above conditions for modified
  21. versions.
  22.  
  23. 
  24. File: octave,  Node: Sending Patches,  Next: Service,  Prev: Bug Reporting,  Up: Trouble
  25.  
  26. Sending Patches for Octave
  27. ==========================
  28.  
  29.    If you would like to write bug fixes or improvements for Octave,
  30. that is very helpful.  When you send your changes, please follow these
  31. guidelines to avoid causing extra work for us in studying the patches.
  32.  
  33.    If you don't follow these guidelines, your information might still be
  34. useful, but using it will take extra work.  Maintaining Octave is a lot
  35. of work in the best of circumstances, and we can't keep up unless you do
  36. your best to help.
  37.  
  38.    * Send an explanation with your changes of what problem they fix or
  39.      what improvement they bring about.  For a bug fix, just include a
  40.      copy of the bug report, and explain why the change fixes the bug.
  41.  
  42.    * Always include a proper bug report for the problem you think you
  43.      have fixed.  We need to convince ourselves that the change is
  44.      right before installing it.  Even if it is right, we might have
  45.      trouble judging it if we don't have a way to reproduce the problem.
  46.  
  47.    * Include all the comments that are appropriate to help people
  48.      reading the source in the future understand why this change was
  49.      needed.
  50.  
  51.    * Don't mix together changes made for different reasons.  Send them
  52.      *individually*.
  53.  
  54.      If you make two changes for separate reasons, then we might not
  55.      want to install them both.  We might want to install just one.
  56.  
  57.    * Use `diff -c' to make your diffs.  Diffs without context are hard
  58.      for us to install reliably.  More than that, they make it hard for
  59.      us to study the diffs to decide whether we want to install them.
  60.      Unidiff format is better than contextless diffs, but not as easy
  61.      to read as `-c' format.
  62.  
  63.      If you have GNU diff, use `diff -cp', which shows the name of the
  64.      function that each change occurs in.
  65.  
  66.    * Write the change log entries for your changes.
  67.  
  68.      Read the `ChangeLog' file to see what sorts of information to put
  69.      in, and to learn the style that we use.  The purpose of the change
  70.      log is to show people where to find what was changed.  So you need
  71.      to be specific about what functions you changed; in large
  72.      functions, it's often helpful to indicate where within the
  73.      function the change was made.
  74.  
  75.      On the other hand, once you have shown people where to find the
  76.      change, you need not explain its purpose. Thus, if you add a new
  77.      function, all you need to say about it is that it is new.  If you
  78.      feel that the purpose needs explaining, it probably does--but the
  79.      explanation will be much more useful if you put it in comments in
  80.      the code.
  81.  
  82.      If you would like your name to appear in the header line for who
  83.      made the change, send us the header line.
  84.  
  85. 
  86. File: octave,  Node: Service,  Prev: Sending Patches,  Up: Trouble
  87.  
  88. How To Get Help with Octave
  89. ===========================
  90.  
  91.    The mailing list (help-octave@bevo.che.wisc.edu) exists for the
  92. discussion of matters related to using and installing Octave.  If would
  93. like to join the discussion, please send a short note to
  94. (help-octave*-request*@bevo.che.wisc.edu).
  95.  
  96.    *Please do not* send requests to be added or removed from the the
  97. mailing list, or other administrative trivia to the list itself.
  98.  
  99.    If you think you have found a bug in the installation procedure,
  100. however, you should send a complete bug report for the problem to
  101. (bug-octave@bevo.che.wisc.edu).  *Note Bug Reporting:: for information
  102. that will help you to submit a useful report.
  103.  
  104. 
  105. File: octave,  Node: Installation,  Next: Emacs,  Prev: Trouble,  Up: Top
  106.  
  107. Installing Octave
  108. *****************
  109.  
  110.    Here is the procedure for installing Octave from scratch on a Unix
  111. system.  For instructions on how to install the binary distributions of
  112. Octave, see *Note Binary Distributions::.
  113.  
  114.    * Run the shell script `configure'.  This will determine the features
  115.      your system has (or doesn't have) and create a file named
  116.      `Makefile' from each of the files named `Makefile.in'.
  117.  
  118.      Here is a summary of the configure options that are most
  119.      frequently used when building Octave:
  120.  
  121.     `--prefix=PREFIX'
  122.           Install Octave in subdirectories below PREFIX.  The default
  123.           value of PREFIX is `/usr/local'.
  124.  
  125.     `--srcdir=DIR'
  126.           Look for Octave sources in the directory DIR.
  127.  
  128.     `--with-f2c'
  129.           Use `f2c' even if a Fortran compiler is available.
  130.  
  131.     `--with-g77'
  132.           Use `g77' to compile Fortran code.
  133.  
  134.     `--enable-shared'
  135.           Create shared libraries.  If you are planning to use
  136.           `--enable-lite-kernelel' or the dynamic loading features, you
  137.           will probably want to use this option.  It will make your
  138.           `.oct' files much smaller and on some systems it may be
  139.           necessary to build shared libraries in order to use
  140.           dynamically linked functions.
  141.  
  142.           You may also want to build a shared version of `libg++', if
  143.           your system doesn't already have one.  Note that a patch is
  144.           needed to build shared versions of version 2.7.2 of `libg++'
  145.           and `libstdc++' on the HP-PA architecture.  You can find the
  146.           patch at
  147.           (ftp://ftp.cygnus.com/pub/g++/libg++-2.7.2-hppa-gcc-fix).
  148.  
  149.     `--enable-dl'
  150.           Use `dlopen' and friends to make Octave capable of dynamically
  151.           linking externally compiled functions.  This only works on
  152.           systems that actually have these functions.  If you plan on
  153.           using this feature, you should probably also use
  154.           `--enable-shared' to reduce the size of your `.oct' files.
  155.  
  156.     `--enable-shl'
  157.           Use `shl_load' and friends to make Octave capable of
  158.           dynamically linking externally compiled functions.  This only
  159.           works on systems that actually have these functions (only
  160.           HP-UX systems).  If you plan on using this feature, you
  161.           should probably also use `--enable-shared' to reduce the size
  162.           of your `.oct' files.
  163.  
  164.     `--enable-lite-kernel'
  165.           Compile smaller kernel.  This currently requires the dynamic
  166.           linking functions `dlopen' or `shl_load' and friends so that
  167.           Octave can load functions at run time that are not loaded at
  168.           compile time.
  169.  
  170.     `--help'
  171.           Print a summary of the options recognized by the configure
  172.           script.
  173.  
  174.      See the file `INSTALL' for more information about the command line
  175.      options used by configure.  That file also contains instructions
  176.      for compiling in a directory other than where the source is
  177.      located.
  178.  
  179.    * Run make.
  180.  
  181.      You will need a recent version of GNU Make.  Modifying Octave's
  182.      makefiles to work with other make programs is probably not worth
  183.      your time.  We recommend you get and compile GNU Make instead.
  184.  
  185.      For plotting, you will need to have gnuplot installed on your
  186.      system.  Gnuplot is a command-driven interactive function plotting
  187.      program.  Gnuplot is copyrighted, but freely distributable.  The
  188.      `gnu' in gnuplot is a coincidence--it is not related to the GNU
  189.      project or the FSF in any but the most peripheral sense.
  190.  
  191.      For version 2.0.5, you must have the GNU C++ compiler (`gcc')
  192.      version 2.7.2 or later to compile Octave.  You will also need
  193.      version 2.7.1 or 2.7.2 of the GNU C++ class library (`libg++').
  194.      If you plan to modify the parser you will also need GNU `bison'
  195.      and `flex'.  If you modify the documentation, you will need GNU
  196.      Texinfo, along with the patch for the `makeinfo' program that is
  197.      distributed with Octave.
  198.  
  199.      GNU Make, `gcc', and `libg++', `gnuplot', `bison', `flex', and
  200.      Texinfo are all available from many anonymous ftp archives.  The
  201.      primary site is (prep.ai.mit.edu), but it is often very busy.  A
  202.      list of sites that mirror the software on `prep' is available by
  203.      anonymous ftp from (ftp://prep.ai.mit.edu/pub/gnu/GNUinfo/FTP), or
  204.      by fingering (fsf@prep.ai.mit.edu).
  205.  
  206.      If you don't have a Fortran compiler, or if your Fortran compiler
  207.      doesn't work like the traditional Unix f77, you will need to have
  208.      the Fortran to C translator `f2c'.  You can get `f2c' from any
  209.      number of anonymous ftp archives.  The most recent version of `f2c'
  210.      is always available from (netlib.att.com).
  211.  
  212.      On an otherwise idle Pentium 133 running Linux, it will take
  213.      somewhere between 1-1/2 to 3 hours to compile everything,
  214.      depending on whether you are building shared libraries.  You will
  215.      need about 100 megabytes of disk storage to work with
  216.      (considerably less if you don't compile with debugging symbols).
  217.      To do that, use the command
  218.  
  219.           make CFLAGS=-O CXXFLAGS=-O LDFLAGS=
  220.  
  221.      instead of just `make'.
  222.  
  223.    * If you encounter errors while compiling Octave, first check the
  224.      list of known problems below to see if there is a workaround or
  225.      solution for your problem.  If not, see *Note Trouble::, for
  226.      information about how to report bugs.
  227.  
  228.    * Once you have successfully compiled Octave, run `make install'.
  229.  
  230.      This will install a copy of octave, its libraries, and its
  231.      documentation in the destination directory.  As distributed,
  232.      Octave is installed in the following directories.  In the table
  233.      below, PREFIX defaults to `/usr/local', VERSION stands for the
  234.      current version number of the interpreter, and ARCH is the type of
  235.      computer on which Octave is installed (for example,
  236.      `i586-unknown-gnu').
  237.  
  238.     `PREFIX/bin'
  239.           Octave and other binaries that people will want to run
  240.           directly.
  241.  
  242.     `PREFIX/lib'
  243.           Libraries like libcruft.a and liboctave.a.
  244.  
  245.     `PREFIX/share'
  246.           Architecture-independent data files.
  247.  
  248.     `PREFIX/include/octave'
  249.           Include files distributed with Octave.
  250.  
  251.     `PREFIX/man/man1'
  252.           Unix-style man pages describing Octave.
  253.  
  254.     `PREFIX/info'
  255.           Info files describing Octave.
  256.  
  257.     `PREFIX/share/octave/VERSION/m'
  258.           Function files distributed with Octave.  This includes the
  259.           Octave version, so that multiple versions of Octave may be
  260.           installed at the same time.
  261.  
  262.     `PREFIX/lib/octave/VERSION/exec/ARCH'
  263.           Executables to be run by Octave rather than the user.
  264.  
  265.     `PREFIX/lib/octave/VERSION/oct/ARCH'
  266.           Object files that will be dynamically loaded.
  267.  
  268.     `PREFIX/share/octave/VERSION/imagelib'
  269.           Image files that are distributed with Octave.
  270.  
  271. * Menu:
  272.  
  273. * Notes::
  274. * Installation Problems::
  275. * Binary Distributions::
  276.  
  277. 
  278. File: octave,  Node: Notes,  Next: Installation Problems,  Prev: Installation,  Up: Installation
  279.  
  280. Notes
  281. =====
  282.  
  283.    * You must use the version of GNU Info distributed with Octave,
  284.      because it includes some changes to allow Octave to search the
  285.      indices of the info files.  If you would like, you should be able
  286.      to replace other copies of the Info browser that you have with the
  287.      one distributed with Octave.  Patches relative to a recent release
  288.      of the GNU Info browser are included in the file `INFO.PATCH' in
  289.      the Octave source distribution.  This modification has been
  290.      submitted to the GNU Info maintainer, and should appear in some
  291.      future release.  Once that happens, the GNU Info browser will no
  292.      longer be distributed with Octave.
  293.  
  294. 
  295. File: octave,  Node: Installation Problems,  Next: Binary Distributions,  Prev: Notes,  Up: Installation
  296.  
  297. Installation Problems
  298. =====================
  299.  
  300.    This section contains a list of problems (and some apparent problems
  301. that don't really mean anything is wrong) that may show up during
  302. installation of Octave.
  303.  
  304.    * On some SCO systems, `info' fails to compile if `HAVE_TERMIOS_H'
  305.      is defined int `config.h'.  Simply removing the definition from
  306.      `info/config.h' should allow it to compile.
  307.  
  308.    * If `configure' finds `dlopen', `dlsym', `dlclose', and `dlerror',
  309.      but not the header file `dlfcn.h', you need to find the source for
  310.      the header file and install it in the directory `usr/include'.
  311.      This is reportedly a problem with Slackware 3.1.  For Linux/GNU
  312.      systems, the source for `dlfcn.h' is in the `ldso' package.
  313.  
  314.    * Building `.oct' files doesn't work.
  315.  
  316.      You should probably have a shared version of `libg++'.  A patch is
  317.      needed to build shared versions of version 2.7.2 of `libg++' and
  318.      `libstdc++' on the HP-PA architecture.  You can find the patch at
  319.      (ftp://ftp.cygnus.com/pub/g++/libg++-2.7.2-hppa-gcc-fix).
  320.  
  321.    * If you encounter errors like
  322.  
  323.           passing `void (*)()' as argument 2 of
  324.             `octave_set_signal_handler(int, void (*)(int))'
  325.  
  326.      or
  327.  
  328.           warning: ANSI C++ prohibits conversion from `(int)' to `(...)'
  329.  
  330.      while compiling `sighandlers.cc', you may need to edit some files
  331.      in the `gcc' include subdirectory to add proper prototypes for
  332.      functions there.  For example, Ultrix 4.2 needs proper
  333.      declarations for the `signal' function and the `SIG_IGN' macro in
  334.      the file `signal.h'.
  335.  
  336.      On some systems the `SIG_IGN' macro is defined to be something like
  337.      this:
  338.  
  339.           #define  SIG_IGN  (void (*)())1
  340.  
  341.      when it should really be something like:
  342.  
  343.           #define  SIG_IGN  (void (*)(int))1
  344.  
  345.      to match the prototype declaration for the `signal' function.  This
  346.      change should also be made for the `SIG_DFL' and `SIG_ERR'
  347.      symbols. It may be necessary to change the definitions in
  348.      `sys/signal.h' as well.
  349.  
  350.      The `gcc' `fixincludes' and `fixproto' scripts should probably fix
  351.      these problems when `gcc' installs its modified set of header
  352.      files, but I don't think that's been done yet.
  353.  
  354.      *You should not change the files in `/usr/include'*.  You can find
  355.      the `gcc' include directory tree by running the command
  356.  
  357.           gcc -print-libgcc-file-name
  358.  
  359.      The directory of `gcc' include files normally begins in the same
  360.      directory that contains the file `libgcc.a'.
  361.  
  362.    * There is a bug with the `makeinfo' program that is distributed with
  363.      Texinfo (through version 3.9) that causes the indices in Octave's
  364.      on-line manual to be generated incorrectly.  If you need to
  365.      recreate the on-line documentation, you should get the `makeinfo'
  366.      program that is distributed with texinfo-3.9 and apply the patch
  367.      for `makeinfo' that is distributed with Octave.  See the file
  368.      `MAKEINFO.PATCH' for more details.
  369.  
  370.    * Some of the Fortran subroutines may fail to compile with older
  371.      versions of the Sun Fortran compiler.  If you get errors like
  372.  
  373.           zgemm.f:
  374.                   zgemm:
  375.           warning: unexpected parent of complex expression subtree
  376.           zgemm.f, line 245: warning: unexpected parent of complex
  377.             expression subtree
  378.           warning: unexpected parent of complex expression subtree
  379.           zgemm.f, line 304: warning: unexpected parent of complex
  380.             expression subtree
  381.           warning: unexpected parent of complex expression subtree
  382.           zgemm.f, line 327: warning: unexpected parent of complex
  383.             expression subtree
  384.           pcc_binval: missing IR_CONV in complex op
  385.           make[2]: *** [zgemm.o] Error 1
  386.  
  387.      when compiling the Fortran subroutines in the `libcruft'
  388.      subdirectory, you should either upgrade your compiler or try
  389.      compiling with optimization turned off.
  390.  
  391.    * On NeXT systems, if you get errors like this:
  392.  
  393.           /usr/tmp/cc007458.s:unknown:Undefined local symbol LBB7656
  394.           /usr/tmp/cc007458.s:unknown:Undefined local symbol LBE7656
  395.  
  396.      when compiling `Array.cc' and `Matrix.cc', try recompiling these
  397.      files without `-g'.
  398.  
  399.    * Some people have reported that calls to shell_cmd and the pager do
  400.      not work on SunOS systems.  This is apparently due to having
  401.      `G_HAVE_SYS_WAIT' defined to be 0 instead of 1 when compiling
  402.      `libg++'.
  403.  
  404.    * On NeXT systems, linking to `libsys_s.a' may fail to resolve the
  405.      following functions
  406.  
  407.           _tcgetattr
  408.           _tcsetattr
  409.           _tcflow
  410.  
  411.      which are part of `libposix.a'.  Unfortunately, linking Octave with
  412.      `-posix' results in the following undefined symbols.
  413.  
  414.           .destructors_used
  415.           .constructors_used
  416.           _objc_msgSend
  417.           _NXGetDefaultValue
  418.           _NXRegisterDefaults
  419.           .objc_class_name_NXStringTable
  420.           .objc_class_name_NXBundle
  421.  
  422.      One kluge around this problem is to extract `termios.o' from
  423.      `libposix.a', put it in Octave's `src' directory, and add it to
  424.      the list of files to link together in the makefile.  Suggestions
  425.      for better ways to solve this problem are welcome!
  426.  
  427.    * If Octave crashes immediately with a floating point exception, it
  428.      is likely that it is failing to initialize the IEEE floating point
  429.      values for infinity and NaN.
  430.  
  431.      If your system actually does support IEEE arithmetic, you should
  432.      be able to fix this problem by modifying the function
  433.      `octave_ieee_init' in the file `lo-ieee.cc' to correctly
  434.      initialize Octave's internal infinity and NaN variables.
  435.  
  436.      If your system does not support IEEE arithmetic but Octave's
  437.      configure script incorrectly determined that it does, you can work
  438.      around the problem by editing the file `config.h' to not define
  439.      `HAVE_ISINF', `HAVE_FINITE', and `HAVE_ISNAN'.
  440.  
  441.      In any case, please report this as a bug since it might be
  442.      possible to modify Octave's configuration script to automatically
  443.      determine the proper thing to do.
  444.  
  445. 
  446. File: octave,  Node: Binary Distributions,  Prev: Installation Problems,  Up: Installation
  447.  
  448. Binary Distributions
  449. ====================
  450.  
  451.    Although Octave is not very difficult to build from its sources, it
  452. is a relatively large program that does require a significant amount of
  453. time and disk space to compile and install.  Because of this, many
  454. people want to be able to obtain binary distributions so they can start
  455. using Octave immediately, without having to bother with the details of
  456. compiling it first.  This is understandable, so I try to maintain a
  457. current collection of binary distributions at
  458. (ftp://ftp.che.wisc.edu/pub/octave/BINARIES).
  459.  
  460.    Please understand, however, that there is only a limited amount of
  461. time available to devote to making binaries, so binaries may not be
  462. immediately available for some platforms.  (Please contact
  463. (bug-octave@bevo.che.wisc.edu) if you are interested in helping make a
  464. binary distribution available for your system.)
  465.  
  466.    Also, binary distributions are limited to static binaries that do not
  467. support dynamic linking.  For earlier versions of Octave, I tried
  468. distributing dynamically linked binaries but that proved to be too much
  469. trouble to support.  If you want to have a copy of Octave that includes
  470. all the features described in this manual, you will have to build it
  471. from the sources yourself, or find someone else who is willing to do it
  472. for you.
  473.  
  474. * Menu:
  475.  
  476. * Installing Octave from a Binary Distribution::
  477. * Creating a Binary Distribution::
  478.  
  479. 
  480. File: octave,  Node: Installing Octave from a Binary Distribution,  Next: Creating a Binary Distribution,  Prev: Binary Distributions,  Up: Binary Distributions
  481.  
  482. Installing Octave from a Binary Distribution
  483. --------------------------------------------
  484.  
  485.    To install Octave from a binary distribution, execute the command
  486.  
  487.      sh ./install-octave
  488.  
  489. in the top level directory of the distribution.
  490.  
  491.    Binary distributions are normally compiled assuming that Octave will
  492. be installed in the following subdirectories of `/usr/local'.
  493.  
  494. `bin'
  495.      Octave and other binaries that people will want to run directly.
  496.  
  497. `lib'
  498.      Shared libraries that Octave needs in order to run.  These files
  499.      are not included if you are installing a statically linked version
  500.      of Octave.
  501.  
  502. `man/man1'
  503.      Unix-style man pages describing Octave.
  504.  
  505. `info'
  506.      Info files describing Octave.
  507.  
  508. `share/octave/VERSION/m'
  509.      Function files distributed with Octave.  This includes the Octave
  510.      version, so that multiple versions of Octave may be installed at
  511.      the same time.
  512.  
  513. `libexec/octave/VERSION/exec/ARCH'
  514.      Executables to be run by Octave rather than the user.
  515.  
  516. `libexec/octave/VERSION/oct/ARCH'
  517.      Object files that will be dynamically loaded.
  518.  
  519. `share/octave/VERSION/imagelib'
  520.      Image files that are distributed with Octave.
  521.  
  522. where VERSION stands for the current version number of the interpreter,
  523. and ARCH is the type of computer on which Octave is installed (for
  524. example, `i486-OS/2').
  525.  
  526.    If these directories don't exist, the script `install-octave' will
  527. create them for you.  The installation script also creates the following
  528. subdirectories of `/usr/local' that are intended for locally installed
  529. functions:
  530.  
  531. `share/octave/site/m'
  532.      Locally installed M-files.
  533.  
  534. `libexec/octave/site/exec/ARCH'
  535.      Locally installed binaries intended to be run by Octave rather
  536.      than by the user.
  537.  
  538. `libexec/octave/site/octave/ARCH'
  539.      Local object files that will be dynamically linked.
  540.  
  541.    If it is not possible for you to install Octave in `/usr/local', or
  542. if you would prefer to install it in a different directory, you can
  543. specify the name of the top level directory as an argument to the
  544. `install-octave' script.  For example:
  545.  
  546.      sh ./install-octave /some/other/directory
  547.  
  548. will install Octave in subdirectories of the directory
  549. `/some/other/directory'.
  550.  
  551. 
  552. File: octave,  Node: Creating a Binary Distribution,  Prev: Installing Octave from a Binary Distribution,  Up: Binary Distributions
  553.  
  554. Creating a Binary Distribution
  555. ------------------------------
  556.  
  557.    Here is how to build a binary distribution for others to use.  If you
  558. want to make a binary distribution for your system available along with
  559. the Octave sources and binaries on (ftp.che.wisc.edu), please follow
  560. this procedure.  For directions explaining how to make the binary
  561. available on the ftp site, please contact
  562. (bug-octave@bevo.che.wisc.edu).
  563.  
  564.    * Unpack the source distribution:
  565.  
  566.           gunzip -c octave-2.0.5.tar.gz | tar xf -
  567.  
  568.    * Change your current directory to the top-level directory of the
  569.      source distribution:
  570.  
  571.           cd octave-2.0.5
  572.  
  573.    * Make the binary distribution:
  574.  
  575.           make binary-dist
  576.  
  577.      This will create a compressed tar file ready for distribution.  It
  578.      will contain statically linked binaries and have a name like
  579.      `octave-2.0.5-i486-OS/2.tar.gz'
  580.  
  581. 
  582. File: octave,  Node: Emacs,  Next: Grammar,  Prev: Installation,  Up: Top
  583.  
  584. Using Emacs With Octave
  585. ***********************
  586.  
  587.    The development of Octave code can greatly be facilitated using Emacs
  588. with Octave mode, a major mode for editing Octave files which can e.g.
  589. automatically indent the code, do some of the typing (with Abbrev mode)
  590. and show keywords, comments, strings, etc. in different faces (with
  591. Font-lock mode on devices that support it).
  592.  
  593.    It is also possible to run Octave from within Emacs, either by
  594. directly entering commands at the prompt in a buffer in Inferior Octave
  595. mode, or by interacting with Octave from within a file with Octave
  596. code.  This is useful in particular for debugging Octave code.
  597.  
  598.    Finally, you can convince Octave to use the Emacs info reader for
  599. `help -i'.
  600.  
  601.    All functionality is provided by the Emacs Lisp package `octave'.
  602. This chapter describes how to set up and use this package.
  603.  
  604.    Please contact (Kurt.Hornik@ci.tuwien.ac.at) if you have any
  605. questions or suggestions on using Emacs with Octave.
  606.  
  607. * Menu:
  608.  
  609. * Installing the Emacs Octave Package::
  610. * Using Octave Mode::
  611. * Running Octave From Within Emacs::
  612. * Using the Emacs Info Reader for Octave::
  613.  
  614. 
  615. File: octave,  Node: Installing the Emacs Octave Package,  Next: Using Octave Mode,  Prev: Emacs,  Up: Emacs
  616.  
  617. Installing the Emacs Octave Package
  618. ===================================
  619.  
  620.    The Emacs package `octave' consists of `octave-mod.el',
  621. `octave-inf.el', and `octave-hlp.el'.  These files, or better yet their
  622. byte-compiled versions, should be somewhere in your Emacs load-path.
  623.  
  624.    If you have GNU Emacs with a version number at least as high as
  625. 19.35, you are all set up, because the package is respectively will be
  626. part of GNU Emacs as of version 19.35.
  627.  
  628.    Otherwise, copy the three files from the `emacs' subdirectory of the
  629. Octave distribution to a place where Emacs can find them (this depends
  630. on how your Emacs was installed).  Byte-compile them for speed if you
  631. want.
  632.  
  633. 
  634. File: octave,  Node: Using Octave Mode,  Next: Running Octave From Within Emacs,  Prev: Installing the Emacs Octave Package,  Up: Emacs
  635.  
  636. Using Octave Mode
  637. =================
  638.  
  639.    If you are lucky, your sysadmins have already arranged everything so
  640. that Emacs automatically goes into Octave mode whenever you visit an
  641. Octave code file as characterized by its extension `.m'.  If not,
  642. proceed as follows.
  643.  
  644.   1. To begin using Octave mode for all `.m' files you visit, add the
  645.      following lines to a file loaded by Emacs at startup time,
  646.      typically your `~/.emacs' file:
  647.  
  648.           (autoload 'octave-mode "octave-mod" nil t)
  649.           (setq auto-mode-alist
  650.                 (cons '("\\.m$" . octave-mode) auto-mode-alist))
  651.  
  652.   2. Finally, to turn on the abbrevs, auto-fill and font-lock features
  653.      automatically, also add the following lines to one of the Emacs
  654.      startup files:
  655.           (add-hook 'octave-mode-hook
  656.                     (lambda ()
  657.                       (abbrev-mode 1)
  658.                       (auto-fill-mode 1)
  659.                       (if (eq window-system 'x)
  660.                           (font-lock-mode 1))))
  661.      See the Emacs manual for more information about how to customize
  662.      Font-lock mode.
  663.  
  664.    In Octave mode, the following special Emacs commands can be used in
  665. addition to the standard Emacs commands.
  666.  
  667. `C-h m'
  668.      Describe the features of Octave mode.
  669.  
  670. `LFD'
  671.      Reindent the current Octave line, insert a newline and indent the
  672.      new line (`octave-reindent-then-newline-and-indent').  An abbrev
  673.      before point is expanded if `abbrev-mode' is non-`nil'.
  674.  
  675. `TAB'
  676.      Indents current Octave line based on its contents and on previous
  677.      lines (`indent-according-to-mode').
  678.  
  679. `;'
  680.      Insert an "electric" semicolon (`octave-electric-semi').  If
  681.      `octave-auto-newline' is non-`nil', typing a `;' automatically
  682.      reindents the current line, inserts a newline and indents the new
  683.      line.
  684.  
  685. ``'
  686.      Start entering an abbreviation (`octave-abbrev-start').  If Abbrev
  687.      mode is turned on, typing ``C-h' or ``?' lists all abbrevs.  Any
  688.      other key combination is executed normally.  Note that all Octave
  689.      abbrevs start with a grave accent.
  690.  
  691. `M-LFD'
  692.      Break line at point and insert continuation marker and alignment
  693.      (`octave-split-line').
  694.  
  695. `M-TAB'
  696.      Perform completion on Octave symbol preceding point, comparing that
  697.      symbol against Octave's reserved words and builtin variables
  698.      (`octave-complete-symbol').
  699.  
  700. `M-C-a'
  701.      Move backward to the beginning of a function
  702.      (`octave-beginning-of-defun').  With prefix argument N, do it that
  703.      many times if N is positive;  otherwise, move forward to the N-th
  704.      following beginning of a function.
  705.  
  706. `M-C-e'
  707.      Move forward to the end of a function (`octave-end-of-defun').
  708.      With prefix argument N, do it that many times if N is positive;
  709.      otherwise, move back to the N-th preceding end of a function.
  710.  
  711. `M-C-h'
  712.      Puts point at beginning and mark at the end of the current Octave
  713.      function, i.e., the one containing point or following point
  714.      (`octave-mark-defun').
  715.  
  716. `M-C-q'
  717.      Properly indents the Octave function which contains point
  718.      (`octave-indent-defun').
  719.  
  720. `M-;'
  721.      If there is no comment already on this line, create a code-level
  722.      comment (started by two comment characters) if the line is empty,
  723.      or an in-line comment (started by one comment character) otherwise
  724.      (`octave-indent-for-comment').  Point is left after the start of
  725.      the comment which is properly aligned.
  726.  
  727. `C-c ;'
  728.      Puts the comment character `#' (more precisely, the string value of
  729.      `octave-comment-start') at the beginning of every line in the
  730.      region (`octave-comment-region').  With just `C-u' prefix
  731.      argument, uncomment each line in the region.  A numeric prefix
  732.      argument N means use N comment characters.
  733.  
  734. `C-c :'
  735.      Uncomments every line in the region (`octave-uncomment-region').
  736.  
  737. `C-c C-p'
  738.      Move one line of Octave code backward, skipping empty and comment
  739.      lines (`octave-previous-code-line').  With numeric prefix argument
  740.      N, move that many code lines backward (forward if N is negative).
  741.  
  742. `C-c C-n'
  743.      Move one line of Octave code forward, skipping empty and comment
  744.      lines (`octave-next-code-line').  With numeric prefix argument N,
  745.      move that many code lines forward (backward if N is negative).
  746.  
  747. `C-c C-a'
  748.      Move to the `real' beginning of the current line
  749.      (`octave-beginning-of-line').  If point is in an empty or comment
  750.      line, simply go to its beginning;  otherwise, move backwards to the
  751.      beginning of the first code line which is not inside a continuation
  752.      statement,  i.e., which does not follow a code line ending in `...'
  753.      or `\', or is inside an open parenthesis list.
  754.  
  755. `C-c C-e'
  756.      Move to the `real' end of the current line (`octave-end-of-line').
  757.      If point is in a code line, move forward to the end of the first
  758.      Octave code line which does not end in `...' or `\' or is inside an
  759.      open parenthesis list.  Otherwise, simply go to the end of the
  760.      current line.
  761.  
  762. `C-c M-C-n'
  763.      Move forward across one balanced begin-end block of Octave code
  764.      (`octave-forward-block').  With numeric prefix argument N, move
  765.      forward across N such blocks (backward if N is negative).
  766.  
  767. `C-c M-C-p'
  768.      Move back across one balanced begin-end block of Octave code
  769.      (`octave-backward-block').  With numeric prefix argument N, move
  770.      backward across N such blocks (forward if N is negative).
  771.  
  772. `C-c M-C-d'
  773.      Move forward down one begin-end block level of Octave code
  774.      (`octave-down-block').  With numeric prefix argument, do it that
  775.      many times;  a negative argument means move backward, but still go
  776.      down one level.
  777.  
  778. `C-c M-C-u'
  779.      Move backward out of one begin-end block level of Octave code
  780.      (`octave-backward-up-block').  With numeric prefix argument, do it
  781.      that many times; a negative argument means move forward, but still
  782.      to a less deep spot.
  783.  
  784. `C-c M-C-h'
  785.      Put point at the beginning of this block, mark at the end
  786.      (`octave-mark-block').  The block marked is the one that contains
  787.      point or follows point.
  788.  
  789. `C-c ]'
  790.      Close the current block on a separate line (`octave-close-block').
  791.      An error is signaled if no block to close is found.
  792.  
  793. `C-c f'
  794.      Insert a function skeleton, prompting for the function's name,
  795.      arguments and return values which have to be entered without parens
  796.      (`octave-insert-defun').
  797.  
  798. `C-c C-h'
  799.      Search the function, operator and variable indices of all info
  800.      files with documentation for Octave for entries (`octave-help').
  801.      If used interactively, the entry is prompted for with completion.
  802.      If multiple matches are found, one can cycle through them using
  803.      the standard `,' (`Info-index-next') command of the Info reader.
  804.  
  805.      The variable `octave-help-files' is a list of files to search
  806.      through and defaults to `'("octave")'.  If there is also an Octave
  807.      Local Guide with corresponding info file, say, `octave-LG', you can
  808.      have `octave-help' search both files by
  809.           (setq octave-help-files '("octave" "octave-LG"))
  810.  
  811.      in one of your Emacs startup files.
  812.  
  813.    A common problem is that the RET key does *not* indent the line to
  814. where the new text should go after inserting the newline.  This is
  815. because the standard Emacs convention is that RET (aka `C-m') just adds
  816. a newline, whereas LFD (aka `C-j') adds a newline and indents it.  This
  817. is particularly inconvenient for users with keyboards which do not have
  818. a special LFD key at all;  in such cases, it is typically more
  819. convenient to use RET as the LFD key (rather than typing `C-j').
  820.  
  821.    You can make RET do this by adding
  822.      (define-key octave-mode-map "\C-m"
  823.        'octave-reindent-then-newline-and-indent)
  824.  
  825. to one of your Emacs startup files.  Another, more generally applicable
  826. solution is
  827.      (defun RET-behaves-as-LFD ()
  828.        (let ((x (key-binding "\C-j")))
  829.          (local-set-key "\C-m" x)))
  830.      (add-hook 'octave-mode-hook 'RET-behaves-as-LFD)
  831.  
  832. (this works for all modes by adding to the startup hooks, without having
  833. to know the particular binding of RET in that mode!).  Similar
  834. considerations apply for using `M-RET' as `M-LFD'.  As Barry A. Warsaw
  835. <bwarsaw@cnri.reston.va.us> says in the documentation for his
  836. `cc-mode', "This is a very common question. `:-)' If you want this to
  837. be the default behavior, don't lobby me, lobby RMS!"
  838.  
  839.    The following variables can be used to customize Octave mode.
  840.  
  841. `octave-auto-newline'
  842.      Non-`nil' means auto-insert a newline and indent after semicolons
  843.      are typed.  The default value is `nil'.
  844.  
  845. `octave-blink-matching-block'
  846.      Non-`nil' means show matching begin of block when inserting a
  847.      space, newline or `;' after an else or end keyword.  Default is
  848.      `t'.  This is an extremely useful feature for automatically
  849.      verifying that the keywords match--if they don't, an error message
  850.      is displayed.
  851.  
  852. `octave-block-offset'
  853.      Extra indentation applied to statements in block structures.
  854.      Default is 2.
  855.  
  856. `octave-continuation-offset'
  857.      Extra indentation applied to Octave continuation lines.  Default
  858.      is 4.
  859.  
  860. `octave-continuation-string'
  861.      String used for Octave continuation lines.  Normally `\'.
  862.  
  863. `octave-mode-startup-message'
  864.      If `t' (default), a startup message is displayed when Octave mode
  865.      is called.
  866.  
  867.    If Font Lock mode is enabled, Octave mode will display
  868.    * strings in `font-lock-string-face'
  869.  
  870.    * comments in `font-lock-comment-face'
  871.  
  872.    * the Octave reserved words (such as all block keywords) and the text
  873.      functions (such as `cd' or `who') which are also reserved using
  874.      `font-lock-keyword-face'
  875.  
  876.    * the builtin operators (`&&', `<>', ...) using
  877.      `font-lock-reference-face'
  878.  
  879.    * the builtin variables (such as `prefer_column_vectors', `NaN' or
  880.      `LOADPATH') in `font-lock-variable-name-face'
  881.  
  882.    * and the function names in function declarations in
  883.      `font-lock-function-name-face'.
  884.  
  885.    There is also rudimentary support for Imenu (currently, function
  886. names can be indexed).
  887.  
  888.    Customization of Octave mode can be performed by modification of the
  889. variable `octave-mode-hook'.  It the value of this variable is
  890. non-`nil', turning on Octave mode calls its value.
  891.  
  892.    If you discover a problem with Octave mode, you can conveniently
  893. send a bug report using `C-c C-b' (`octave-submit-bug-report').  This
  894. automatically sets up a mail buffer with version information already
  895. added.  You just need to add a description of the problem, including a
  896. reproducible test case and send the message.
  897.  
  898. 
  899. File: octave,  Node: Running Octave From Within Emacs,  Next: Using the Emacs Info Reader for Octave,  Prev: Using Octave Mode,  Up: Emacs
  900.  
  901. Running Octave From Within Emacs
  902. ================================
  903.  
  904.    The package `octave' provides commands for running an inferior
  905. Octave process in a special Emacs buffer.  Use
  906.      M-x run-octave
  907.  
  908. to directly start an inferior Octave process.  If Emacs does not know
  909. about this command, add the line
  910.      (autoload 'run-octave "octave-inf" nil t)
  911.  
  912. to your `.emacs' file.
  913.  
  914.    This will start Octave in a special buffer the name of which is
  915. specified by the variable `inferior-octave-buffer' and defaults to
  916. `"*Inferior Octave*"'.  From within this buffer, you can interact with
  917. the inferior Octave process `as usual', i.e., by entering Octave
  918. commands at the prompt.  The buffer is in Inferior Octave mode, which
  919. is derived from the standard Comint mode, a major mode for interacting
  920. with an inferior interpreter.  See the documentation for `comint-mode'
  921. for more details, and use `C-h b' to find out about available special
  922. keybindings.
  923.  
  924.    You can also communicate with an inferior Octave process from within
  925. files with Octave code (i.e., buffers in Octave mode), using the
  926. following commands.
  927.  
  928. `C-c i l'
  929.      Send the current line to the inferior Octave process
  930.      (`octave-send-line').  With positive prefix argument N, send that
  931.      many lines.  If `octave-send-line-auto-forward' is non-`nil', go
  932.      to the next unsent code line.
  933.  
  934. `C-c i b'
  935.      Send the current block to the inferior Octave process
  936.      (`octave-send-block').
  937.  
  938. `C-c i f'
  939.      Send the current function to the inferior Octave process
  940.      (`octave-send-defun').
  941.  
  942. `C-c i r'
  943.      Send the region to the inferior Octave process
  944.      (`octave-send-region').
  945.  
  946. `C-c i s'
  947.      Make sure that `inferior-octave-buffer' is displayed
  948.      (`octave-show-process-buffer').
  949.  
  950. `C-c i h'
  951.      Delete all windows that display the inferior Octave buffer
  952.      (`octave-hide-process-buffer').
  953.  
  954. `C-c i k'
  955.      Kill the inferior Octave process and its buffer
  956.      (`octave-kill-process').
  957.  
  958.    The effect of the commands which send code to the Octave process can
  959. be customized by the following variables.
  960. `octave-send-echo-input'
  961.      Non-`nil' means echo input sent to the inferior Octave process.
  962.      Default is `t'.
  963.  
  964. `octave-send-show-buffer'
  965.      Non-`nil' means display the buffer running the Octave process after
  966.      sending a command (but without selecting it).  Default is `t'.
  967.  
  968.    If you send code and there is no inferior Octave process yet, it
  969. will be started automatically.
  970.  
  971.    The startup of the inferior Octave process is highly customizable.
  972. The variable `inferior-octave-startup-args' can be used for specifying
  973. command lines arguments to be passed to Octave on startup as a list of
  974. strings.  For example, to suppress the startup message and use
  975. `traditional' mode, set this to `'("-q" "--traditional")'.  You can
  976. also specify a startup file of Octave commands to be loaded on startup;
  977. note that these commands will not produce any visible output in the
  978. process buffer.  Which file to use is controlled by the variable
  979. `inferior-octave-startup-file'.  If this is `nil', the file
  980. `~/.emacs-octave' is used if it exists.
  981.  
  982.    And finally, `inferior-octave-mode-hook' is run after starting the
  983. process and putting its buffer into Inferior Octave mode.  Hence, if you
  984. like the up and down arrow keys to behave in the interaction buffer as
  985. in the shell, and you want this buffer to use nice colors, add
  986.      (add-hook 'inferior-octave-mode-hook
  987.                (lambda ()
  988.                  (turn-on-font-lock)
  989.                  (define-key inferior-octave-mode-map [up]
  990.                    'comint-previous-input)
  991.                  (define-key inferior-octave-mode-map [down]
  992.                    'comint-next-input)))
  993.  
  994. to your `.emacs' file.  You could also swap the roles of `C-a'
  995. (`beginning-of-line') and `C-c C-a' (`comint-bol') using this hook.
  996.  
  997.      *Note:* If you set your Octave prompts to something different from
  998.      the defaults, make sure that `inferior-octave-prompt' matches them.
  999.      Otherwise, *nothing* will work, because Emacs will have no idea
  1000.      when Octave is waiting for input, or done sending output.
  1001.  
  1002. 
  1003. File: octave,  Node: Using the Emacs Info Reader for Octave,  Prev: Running Octave From Within Emacs,  Up: Emacs
  1004.  
  1005. Using the Emacs Info Reader for Octave
  1006. ======================================
  1007.  
  1008.    You can also have Octave's `help -i' command invoke the Emacs Info
  1009. reader.  To do this, you'll need `gnuserv', which can be retrieved from
  1010. any GNU Emacs Lisp Code Directory archive, e.g.
  1011. (ftp://ftp.cis.ohio-state.edu/pub/gnu/emacs/elisp-archive), in the
  1012. `packages' subdirectory.  The alpha version of an enhanced version of
  1013. gnuserv is available at
  1014. (ftp://ftp.wellfleet.com/netman/psmith/emacs/gnuserv-2.1alpha.tar.gz).
  1015.  
  1016.    If `gnuserv' is installed, add the lines
  1017.      (autoload 'octave-help "octave-hlp" nil t)
  1018.      (require 'gnuserv)
  1019.      (gnuserv-start)
  1020.  
  1021. to your `.emacs' file.
  1022.  
  1023.    You can use either `plain' Emacs Info or the function `octave-help'
  1024. as your Octave info reader (for `help -i').  In the former case, set
  1025. the Octave variable `INFO_PROGRAM' to `"info-emacs-info"'.  The latter
  1026. is perhaps more attractive because it allows to look up keys in the
  1027. indices of *several* info files related to Octave (provided that the
  1028. Emacs variable `octave-help-files' is set correctly).  In this case,
  1029. set `INFO_PROGRAM' to `"info-emacs-octave-help"'.
  1030.  
  1031.    If you use Octave from within Emacs, these settings are best done in
  1032. the startup file `~/.emacs-octave' (or the file pointed to by the Emacs
  1033. variable `inferior-octave-startup-file').
  1034.  
  1035. 
  1036. File: octave,  Node: Grammar,  Next: Copying,  Prev: Emacs,  Up: Top
  1037.  
  1038. Grammar
  1039. *******
  1040.  
  1041.    Someday I hope to expand this to include a semi-formal description of
  1042. Octave's language.
  1043.  
  1044. * Menu:
  1045.  
  1046. * Keywords::
  1047.  
  1048. 
  1049. File: octave,  Node: Keywords,  Prev: Grammar,  Up: Grammar
  1050.  
  1051. Keywords
  1052. ========
  1053.  
  1054.    The following identifiers are keywords, and may not be used as
  1055. variable or function names:
  1056.  
  1057.      all_va_args             endwhile
  1058.      break                   for
  1059.      case                    function
  1060.      catch                   global
  1061.      continue                gplot
  1062.      else                    gsplot
  1063.      elseif                  if
  1064.      end                     otherwise
  1065.      end_try_catch           return
  1066.      end_unwind_protect      switch
  1067.      endfor                  try
  1068.      endfunction             unwind_protect
  1069.      endif                   unwind_protect_cleanup
  1070.      endswitch               while
  1071.  
  1072.    The following command-like functions are also speical.  They may be
  1073. used as simple variable names, but not as formal parameters for
  1074. functions, or as the names of structure variables.  Failed assignments
  1075. leave them undefined (you can recover the orginal definition as a
  1076. function using clear).
  1077.  
  1078.      casesen       echo          load          show
  1079.      cd            edit_history  ls            type
  1080.      chdir         format        more          which
  1081.      clear         help          run_history   who
  1082.      diary         history       save          whos
  1083.      dir           hold          set
  1084.  
  1085.